import { request } from '@/utils/request'
import type { ApiResponse } from '@/utils/request'

/**
 * 学校信息API
 */
export interface SchoolInfoQuery {
  schoolCode?: string
  schoolName?: string
  schoolType?: string
  province?: string
  city?: string
  district?: string
  pageNum: number
  pageSize: number
}

export interface SchoolInfo {
[x: string]: any
  id?: number
  schoolCode: string
  schoolName: string
  schoolType?: string
  establishedDate?: string
  address?: string
  postcode?: string
  telephone?: string
  email?: string
  website?: string
  logoUrl?: string
  description?: string
  province?: string
  city?: string
  district?: string
  reservedField1?: string
  reservedField2?: string
  reservedField3?: string
  reservedField4?: number
  reservedField5?: string
  createBy?: string
  createTime?: string
  updateBy?: string
  updateTime?: string
}

export interface SchoolInfoPageResult {
  records: SchoolInfo[]
  total: number
  size: number
  current: number
  pages: number
}

/**
 * 分页查询学校信息
 * @param query 查询参数
 * @returns 分页数据
 */
export function pageSchoolInfo(query: SchoolInfoQuery) {
  return request.post<ApiResponse<SchoolInfoPageResult>>('/api/school/info/page', query)
}

/**
 * 获取学校信息详情
 * @param id 学校ID
 * @returns 学校信息
 */
export function getSchoolInfo(id: number) {
  return request.get<ApiResponse<SchoolInfo>>(`/api/school/info/${id}`)
}

/**
 * 根据编码获取学校信息
 * @param code 学校编码
 * @returns 学校信息
 */
export function getSchoolInfoByCode(code: string) {
  return request.get<ApiResponse<SchoolInfo>>(`/api/school/info/code/${code}`)
}

/**
 * 新增学校信息
 * @param data 学校信息
 * @returns 操作结果
 */
export function addSchoolInfo(data: SchoolInfo) {
  return request.post<ApiResponse<boolean>>('/api/school/info', data)
}

/**
 * 更新学校信息
 * @param data 学校信息
 * @returns 操作结果
 */
export function updateSchoolInfo(data: SchoolInfo) {
  return request.put<ApiResponse<boolean>>('/api/school/info', data)
}

/**
 * 删除学校信息
 * @param id 学校ID
 * @returns 操作结果
 */
export function deleteSchoolInfo(id: number) {
  return request.delete<ApiResponse<boolean>>(`/api/school/info/${id}`)
}

/**
 * 批量删除学校信息
 * @param ids ID数组
 * @returns 操作结果
 */
export function batchDeleteSchoolInfo(ids: number[]) {
  return request.delete<ApiResponse<boolean>>('/api/school/info/batch', ids)
} 